import { ApiProperty } from '@nestjs/swagger'
import {
  IsEnum,
  IsNotEmpty,
  IsNumber,
  IsOptional,
  IsString,
  MaxLength
} from 'class-validator'
import { AwardRuleTypeEnum } from 'src/types/awardRule'

export class CreateAwardRuleDto {
  @ApiProperty({ example: '迟到', description: '奖惩名称' })
  @IsNotEmpty({ message: '奖惩名称不能为空' })
  @IsString({ message: '奖惩名称必须为字符串' })
  @MaxLength(10, { message: '奖惩名称不能超过10个字符' })
  name: string
  @ApiProperty({ example: 50, description: '奖惩分数' })
  @IsNotEmpty({ message: '奖惩分数不能为空' })
  @IsNumber({}, { message: '奖惩分数必须为数字' })
  score: number
  @ApiProperty({
    example: 1,
    description: '奖惩类型',
    enum: AwardRuleTypeEnum,
    default: AwardRuleTypeEnum['奖']
  })
  @IsEnum(AwardRuleTypeEnum, { message: '奖惩类型不符合规范' })
  type: number
  @ApiProperty({
    example: '迟到的描述',
    description: '奖惩名称描述',
    required: false
  })
  @IsString({ message: '描述必须为字符串' })
  @MaxLength(50, { message: '描述不得超过50个字符' })
  @IsOptional()
  desc?: string
}
